<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>"/>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>青鸟租房 - 首页</title>
	<link type="text/css" rel="stylesheet" href="css/style.css" />
	<script type="text/javascript" src="scripts/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="scripts/function.js"></script>
	<script type="text/javascript">
	var pageIndex = <s:property value="pageIndex" />;
	var totalPages = <s:property value="totalPages" />;
	$(function(){
		if (pageIndex <= 1) {
			$("#pageSplit").append("上一页");
		} else {
			$("#pageSplit").append("<a href='search.action?search=${sc.districtId }-0-${sc.fromPrice }-${sc.toPrice }-${sc.houseTypeId }-${sc.typeId }&pageIndex=" + (pageIndex - 1) + "'><span>上一页</span></a>");
		}
		var start = 0;
		var end = 0;
		if (pageIndex < 5) {
			start = 1;
		} else {
			start = pageIndex - 4;
		}
		if (pageIndex + 5 > totalPages) {
			end = totalPages;
		} else {
			end = pageIndex + 5;
		}
		for (var i = start; i <= end; i++) {
			if (i != pageIndex) {
				$("#pageSplit").append("<a href='search.action?search=${sc.districtId }-0-${sc.fromPrice }-${sc.toPrice }-${sc.houseTypeId }-${sc.typeId }&pageIndex=" + i + "'><span>" + i + "</span></a>");
			} else {
				$("#pageSplit").append("<span>" + i + "</span>");
			}
			
		}
		if (pageIndex >= totalPages) {
			$("#pageSplit").append("下一页");
		} else {
			$("#pageSplit").append("<a href='search.action?search=${sc.districtId }-0-${sc.fromPrice }-${sc.toPrice }-${sc.houseTypeId }-${sc.typeId }&pageIndex=" + (pageIndex + 1) + "'><span>下一页</span></a>");
		}
	});
	</script>
</head>
<body>
<jsp:include page="head.jsp" />

<div class="wrap">
	<dl class="dl_list_tag clear_box">
		<dt>区域：</dt>
		<s:if test="sc.districtId!=0">
			<dd><a href="search.action?search=0-0-${sc.fromPrice }-${sc.toPrice }-${sc.houseTypeId }-${sc.typeId }">不限</a></dd>
		</s:if>
		<s:else>
			<dd><strong>不限</strong></dd>
		</s:else>
		<s:iterator value="districts" var="d">
			<s:if test="#d.id!=sc.districtId">
				<dd><a href="search.action?search=${d.id }-0-${sc.fromPrice }-${sc.toPrice }-${sc.houseTypeId }-${sc.typeId }">${d.name }</a></dd>
			</s:if>
			<s:else>
				<dd><strong>${d.name }</strong></dd>
			</s:else>
		</s:iterator>
	</dl>
	<dl class="dl_list_tag clear_box">
		<dt>租金：</dt>
		<s:if test="sc.fromPrice==0&&sc.toPrice==0">
			<dd><strong>不限</strong></dd>
		</s:if>
		<s:else>
			<dd><a href="search.action?search=${sc.districtId }-0-0-0-${sc.houseTypeId }-${sc.typeId }">不限</a></dd>
		</s:else>
		<s:if test="sc.fromPrice==0&&sc.toPrice==500">
			<dd><strong>500以下</strong></dd>
		</s:if>
		<s:else>
			<dd><a href="search.action?search=${sc.districtId }-0-0-500-${sc.houseTypeId }-${sc.typeId }">500以下</a></dd>
		</s:else>
		<s:if test="sc.fromPrice!=500">
			<dd><a href="search.action?search=${sc.districtId }-0-500-800-${sc.houseTypeId }-${sc.typeId }">500-800</a></dd>
		</s:if>
		<s:else>
			<dd><strong>500-800</strong></dd>
		</s:else>
		<s:if test="sc.fromPrice!=800">
			<dd><a href="search.action?search=${sc.districtId }-0-800-1000-${sc.houseTypeId }-${sc.typeId }">800-1000</a></dd>
		</s:if>
		<s:else>
			<dd><strong>800-1000</strong></dd>
		</s:else>
		<s:if test="sc.fromPrice!=1000">
			<dd><a href="search.action?search=${sc.districtId }-0-1000-1500-${sc.houseTypeId }-${sc.typeId }">1000-1500</a></dd>
		</s:if>
		<s:else>
			<dd><strong>1000-1500</strong></dd>
		</s:else>
		<s:if test="sc.fromPrice!=1500">
			<dd><a href="search.action?search=${sc.districtId }-0-1500-2000-${sc.houseTypeId }-${sc.typeId }">1500-2000</a></dd>
		</s:if>
		<s:else>
			<dd><strong>1500-2000</strong></dd>
		</s:else>
		<s:if test="sc.fromPrice!=2000">
			<dd><a href="search.action?search=${sc.districtId }-0-2000-3000-${sc.houseTypeId }-${sc.typeId }">2000-3000</a></dd>
		</s:if>
		<s:else>
			<dd><strong>2000-3000</strong></dd>
		</s:else>
		<s:if test="sc.fromPrice!=3000">
			<dd><a href="search.action?search=${sc.districtId }-0-3000-5000-${sc.houseTypeId }-${sc.typeId }">3000-5000</a></dd>
		</s:if>
		<s:else>
			<dd><strong>3000-5000</strong></dd>
		</s:else>
		<s:if test="sc.fromPrice!=5000">
			<dd><a href="search.action?search=${sc.districtId }-0-5000-0-${sc.houseTypeId }-${sc.typeId }">5000以上</a></dd>
		</s:if>
		<s:else>
			<dd><strong>5000以上</strong></dd>
		</s:else>
	</dl>
	<dl class="dl_list_tag clear_box">
		<dt>房型：</dt>
		<s:if test="sc.houseTypeId!=0">
			<dd><a href="search.action?search=${sc.districtId }-0-${sc.fromPrice }-${sc.toPrice }-0-${sc.typeId }">不限</a></dd>
		</s:if>
		<s:else>
			<dd><strong>不限</strong></dd>
		</s:else>
		<s:iterator value="houseTypes" var="ht">
			<s:if test="#ht.id!=sc.houseTypeId">
				<dd><a href="search.action?search=${sc.districtId }-0-${sc.fromPrice }-${sc.toPrice }-${ht.id }-${sc.typeId }"><s:property value="name"/></a></dd>
			</s:if>
			<s:else>
				<dd><strong><s:property value="name"/></strong></dd>
			</s:else>
		</s:iterator>
	</dl>
	<dl class="dl_list_tag clear_box">
		<dt>类型：</dt>
		<s:if test="sc.typeId!=0">
			<dd><a href="search.action?search=${sc.districtId }-0-${sc.fromPrice }-${sc.toPrice }-${sc.houseTypeId }-0">不限</a></dd>
		</s:if>
		<s:else>
			<dd><strong>不限</strong></dd>
		</s:else>
		<s:iterator value="types" var="t">
			<s:if test="#t.id!=sc.typeId">
				<dd><a href="search.action?search=${sc.districtId }-0-${sc.fromPrice }-${sc.toPrice }-${sc.houseTypeId }-${t.id }"><s:property value="name"/></a></dd>
			</s:if>
			<s:else>
				<dd><strong><s:property value="name"/></strong></dd>
			</s:else>
		</s:iterator>
	</dl>
</div>

<div class="main wrap">
	<table class="house-list">
		<c:if test="${houses!=null }">
			<c:forEach items="${houses}" var="h">
				<tr>
					<td class="house-thumb"><span><a href="show.action?id=${h.id }"><img class="small" src="upload/housePhoto/${h.photoName }" /></a></span></td>
					<td>
						<dl>
							<dt>${h.title }</dt>
							<dd>
								${h.street.district.name }区${h.street.name },${h.floorage }平米<br />
								联系方式：${h.contact }
							</dd>
						</dl>
					</td>
					<td class="house-type">${h.type.name }</td>
					<td class="house-price"><span>${h.price }</span>元/月</td>
				</tr>
			</c:forEach>
		</c:if>
		<c:if test="${houses==null }">
			哎呀，没有找到符合要求的房子。
		</c:if>
	</table>
	<div id="pageSplit"></div>
</div>
<div id="footer" class="wrap">
	<dl>
    	<dt>青鸟租房 &copy; 2010 北大青鸟 京ICP证1000001号</dt>
        <dd>关于我们 · 联系方式 · 意见反馈 · 帮助中心</dd>
    </dl>
</div>
</body>
</html>